package gao.xiaolei.dao;

import gao.xiaolei.entity.TestRunLog;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository("TestRunLogDao")
public interface TestRunLogDao extends JpaRepository<TestRunLog,String> {

    public List<TestRunLog> findByTestRunIdOrderByCreateDateDesc(String testRunId);

    public List<TestRunLog> findByTestRunId(String testRunId);

    @Query("select createDate from TestRunLog where id=:id")
    public LocalDateTime getCreateDate(@Param("id") String id);

    @Query("select id from TestRunLog where testRunId in :testRunId")
    public List<String> findIdsByTestRunIdIn(@Param("testRunId") List<String> testRunIds);

    public List<TestRunLog> findAllByIdIn(List<String> ids);

    @Modifying
    public void deleteAllByTestRunIdIn(List<String> testRunId);
}
